﻿using BasicInformation.ApiWrite.Application.Command.Storage;
using BasicInformation.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BasicInformation.ApiWrite.Controllers
{
    /// <summary>
    /// 工单仓库管理——写
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class StorageController : ControllerBase
    {
        private readonly IMediator mediator;

        public StorageController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 工单仓库管理添加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> AddStorage(AddStorageCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 工单仓库管理删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<int>> DelStorage([FromQuery] DelStorageCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 工单仓库管理修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> UpdateStorage(UpdateStorageCommand request)
        {
            return await mediator.Send(request);
        }

    }
}
